package cn.xizikelif.basic.util;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class AjaxResult {

    private Boolean success;
    private String message;
    private Object resultObj;

    public AjaxResult success(){
       return AjaxResult.me().setSuccess(true).setMessage("操作成功！");
    }

    public AjaxResult fail(){
        return AjaxResult.me().setSuccess(false).setMessage("操作失败！");
    }



    public AjaxResult fail(String message){
        return AjaxResult.me().setSuccess(false).setMessage(message);
    }


    public static AjaxResult me(){
        return new AjaxResult();
    }

    public AjaxResult setSuccess(Boolean success) {
        this.success = success;
        return this;
    }

    public AjaxResult setMessage(String message) {
        this.message = message;
        return this;
    }

    public AjaxResult setResultObj(Object resultObj) {
        this.resultObj = resultObj;
        return this;
    }
}
